package kata02;

public class IterationChop {
    public static int findIndex (int element, int[] items) {
        int start = 0;
        int end = items.length - 1;
        while (start <= end) {
            int middle = (start + end) / 2;
            if (element < items[middle]) {
                end = middle - 1;
            } else if (element > items[middle]) {
                start = middle + 1;
            } else {
                return middle;
            }
        }
        return -1;
    }
}
